package com.lyz.util;

import org.apache.log4j.Logger;

public class ClassUtil {
	
	private static final Logger logger = Logger.getLogger(ClassUtil.class);
	/**
	 * 反射机制实例化类
	 * @param className
	 * @return
	 */
	public static Object newInstance(String className){
		if(className == null){
			return null;
		}
		Class cls = null;
		Object obj = null;
		try {
			cls = Class.forName(className);
			obj = cls.newInstance();
		} catch (ClassNotFoundException e) {
			logger.error("class not found!",e);
			return null;
		} catch (IllegalAccessException e){
			logger.error(e);
		} catch (InstantiationException e){
			logger.error(e);
		}
		
		return obj;
	}
}
